Crate crypto_primes

source ·
Expand description

Prime number tools for crypto-bigint

crate Docs License Build Status Coverage

This library implements prime number generation and primality checking for crypto-bigint integers. In particular:

  • Generating random primes and safe primes of given bit size;
  • Sieving iterator;
  • Miller-Rabin test;
  • Strong and extra strong Lucas tests, and Lucas-V test.

See the documentation for the specific tests for more information and references.

Modules

  • Components to build your own primality test. Handle with care.

Traits

  • Provides a generic way to access methods for random prime number generation and primality checking, wrapping the standalone functions (is_prime_with_rng etc).

Functions

  • generate_primedefault-rng
    Returns a random prime of size bit_length using OsRng as the RNG. If bit_length is None, the full size of Uint<L> is used.
  • Returns a random prime of size bit_length using the provided RNG. If bit_length is None, the full size of Uint<L> is used.
  • Returns a random safe prime (that is, such that (n - 1) / 2 is also prime) of size bit_length using OsRng as the RNG. If bit_length is None, the full size of Uint<L> is used.
  • Returns a random safe prime (that is, such that (n - 1) / 2 is also prime) of size bit_length using the provided RNG. If bit_length is None, the full size of Uint<L> is used.
  • is_primedefault-rng
    Checks probabilistically if the given number is prime using OsRng as the RNG.
  • Checks probabilistically if the given number is prime using the provided RNG.
  • is_safe_primedefault-rng
    Checks probabilistically if the given number is a safe prime (that is, such that (n - 1) / 2 is also prime) using OsRng as the RNG.
  • Checks probabilistically if the given number is a safe prime using the provided RNG.